package com.example.canaltest.listener;

import com.alibaba.fastjson.JSONObject;
import com.example.canaltest.mapper.SysDataModelMapper;
import com.yellowframework.cloud.domain.system.SysDataModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import top.javatool.canal.client.annotation.CanalTable;
import top.javatool.canal.client.handler.EntryHandler;

import javax.annotation.Resource;

/**
 * @author W-JinDuo
 * @version 1.0.0
 * @ClassName SysUserEntity.java
 * @Description 用户表数据库监听
 * @createTime 2022-05-06 17
 */
@Slf4j
@Component
@CanalTable(value = "sys_data_model")
public class SysDataModelListener implements EntryHandler<SysDataModel> {

    @Resource
    private SysDataModelMapper sysDataModelMapper;

    @Override
    public void insert(SysDataModel data) {
        log.info("新增：" + JSONObject.toJSONString(data));
        sysDataModelMapper.insert(data);
    }

    @Override
    public void update(SysDataModel before, SysDataModel after) {
        log.info("修改-前：" + JSONObject.toJSONString(before));
        log.info("修改-后：" + JSONObject.toJSONString(after));
    }

    @Override
    public void delete(SysDataModel sysUserEntity) {
        log.info("删除：" + JSONObject.toJSONString(sysUserEntity));
    }

}
